<%--
  Created by IntelliJ IDEA.
  User: Rui
  Date: 2018/9/8
  Time: 9:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html style="background-color: #fff;">
<head>
    <%@include file="../../../resources/inc/head.jsp" %>
</head>
<body>
<expect-x:tip tipMessage="标识“*”的选项为必填项，其余为选填项。;请按提示信息填写每一个字段" widthClass="full-width-85"/>

<div class="layui-form common-form" lay-filter="layuiadmin-form-systemType" id="layuiadmin-form-systemType" style="padding: 20px;">
    <div class="layui-form-item">
        <input type="hidden"  name="id">
        <label class="layui-form-label"><span class="require-field">*</span>AppId </label>
        <div class="layui-input-inline">
            <input type="text" value="${systemType.typeCode}"maxlength="45" name="appId" lay-verify="required" placeholder="请输入AppId" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="require-field">*</span>AppSecret</label>
        <div class="layui-input-inline">
            <input type="text" value="${systemType.typeCode}"maxlength="45" name="appSecret" lay-verify="required" placeholder="请输入Appsecret" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="LAY-submit" id="LAY-submit" value="确认">
    </div>
</div>

<%@include file="../../../resources/inc/footer.jsp" %>
<script>
    layui.config({
        base: '<%=basePath%>resources/lib/layuiAdmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'upload'], function(){
        var $ = layui.$
            ,form = layui.form
            ,upload = layui.upload ;


    })
    var id ='${id}'
    function createSubmit() {
        var layer=layui.layer;
        var submitID = 'LAY-submit';
        layui.form.on('submit('+ submitID +')', function(data){
            var formData = data.field;

            $.ajax({
            type: "get",
            url: '<%=basePath%>merchantApplication/app/'+id+'.html',
            data:{appId: formData.appId,appSecret:formData.appSecret,merchantNo:"${merchantApplication.merchantNo}",applicationNo:"${merchantApplication.agentNo}"},
            success: function (data) {
            layer.closeAll("loading");
            data = JSON.parse(data);
            if (data.success) {
            layer.msg("配置成功");
                setTimeout(function () {
                    window.parent.location.reload(); //刷新父页面
                    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                    parent.layer.close(index);
                }, 1000);
            } else {
            layer.msg(data.message)
            }
            }
        })

    })
        $("#"+submitID).trigger('click');
    }
</script>
</body>
</html>
